<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>兑换券查看管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#btnExport").click(function(){
				top.$.jBox.confirm("确认要导出兑换券数据吗？","系统提示",function(v,h,f){
					if(v=="ok"){
						$("#searchForm").attr("action","${ctx}/crab/couponDetail/export");
						$("#searchForm").submit();
					}
				},{buttonsFocus:1});
				top.$('.jbox-body .jbox-icon').css('top','55px');
			});
			$("#btnImport").click(function(){
				$.jBox($("#importBox").html(), {title:"导入数据", buttons:{"关闭":true}, 
					bottomText:"导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"});
			});
			$("#btnBatchRemarks").click(function(){
				$.jBox($("#batchRemarksBox").html(), {title:"批量备注", buttons:{"关闭":true}});
			});
			$("#btnBatchActivate").click(function(){
				$.jBox($("#batchActivateBox").html(), {title:"批量激活", buttons:{"关闭":true}});
			});
			$("#btnBatchUnActivate").click(function(){
				$.jBox($("#batchUnActivateBox").html(), {title:"批量未激活", buttons:{"关闭":true}});
			});
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").attr("action","${ctx}/crab/couponDetail/list");
			$("#searchForm").submit();
        	return false;
        }
		
		function clearForm(){
			$("#activatedState").val('');
			$("#useState").val('');
			$("#numStart").val('');
			$("#numEnd").val('');
			$("#searchForm").attr("action","${ctx}/crab/couponDetail/list");
			$("#searchForm").submit();
        	return false;
		}
		
	</script>
</head>
<body>
	<shiro:hasPermission name="crab:carrier:edit">
	<div id="batchRemarksBox" class="hide">
		<form action="${ctx}/crab/couponDetail/batchRemarks?couponId=${couponDetail.couponId}&couponName=${couponDetail.couponName}" method="post" class="form-search">
			</br>
			&nbsp;&nbsp;兑换券号:
			<input type="text" id="numStart1" name="numStart" class="required" style="width:110px"/>至
			<input type="text" id="numEnd1" name="numEnd" class="required" style="width:110px"/>
			<span class="help-inline"><font color="red">*</font> </span></br></br>
			&nbsp;&nbsp;备注：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<textarea id="remarks" name="remarks" rows="3" maxlength="255" htmlEscape="false" class="required"></textarea>
			<span class="help-inline"><font color="red">*</font> </span></br></br>
			<div style="text-align:center;">
				<input id="batchRemarks" class="btn btn-primary" type="submit"  value="提交"/>
			</div>	
		</form>
	</div>
	<div id="batchActivateBox" class="hide">
		<form action="${ctx}/crab/couponDetail/batchActivate?couponId=${couponDetail.couponId}&couponName=${couponDetail.couponName}" method="post" class="form-search">
			</br>
			&nbsp;&nbsp;兑换券号:
			<input type="text" name="numStart" class="required" style="width:110px"/>至
			<input type="text" name="numEnd" class="required" style="width:110px"/>
			<input name="activatedState" type="hidden" value="1"/>
			<span class="help-inline"><font color="red">*</font> </span></br></br>
			<div style="text-align:center;">
				<input id="btnImportSubmit" class="btn btn-primary" type="submit" value="提交"/>
			</div>	
		</form>	
	</div>
	<div id="batchUnActivateBox" class="hide">
		<form action="${ctx}/crab/couponDetail/batchActivate?couponId=${couponDetail.couponId}&couponName=${couponDetail.couponName}" method="post" class="form-search">
			</br>
			&nbsp;&nbsp;兑换券号:
			<input type="text" name="numStart" class="required" style="width:110px"/>至
			<input type="text" name="numEnd" class="required" style="width:110px"/>
			<input name="activatedState" type="hidden" value="0"/>
			<span class="help-inline"><font color="red">*</font> </span></br></br>
			<div style="text-align:center;">
				<input id="batchUnActivate" class="btn btn-primary" type="submit" value="提交"/>
			</div>	
		</form>		
	</div>
	</shiro:hasPermission>
	<shiro:hasPermission name="crab:carrier:import">
	<div id="importBox" class="hide">
		<form id="importForm" action="${ctx}/crab/couponDetail/import?couponId=${couponDetail.couponId}&couponName=${couponDetail.couponName}" method="post" enctype="multipart/form-data"
			class="form-search" style="padding-left:20px;text-align:center;" onsubmit="loading('正在导入，请稍等...');"><br/>
			<input id="uploadFile" name="file" type="file" style="width:330px"/><br/><br/>　　
			<input id="btnImportSubmit" class="btn btn-primary" type="submit" value="   导    入   "/>
			<a href="${ctx}/crab/couponDetail/import/template">下载模板</a>
		</form>
	</div>
	</shiro:hasPermission>
	<ul class="nav nav-tabs">
		<li class="active"><a>兑换券查看列表</a></li>
	</ul>
	<form:form id="searchForm" modelAttribute="couponDetail" action="${ctx}/crab/couponDetail/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<form:input path="couponId" htmlEscape="false" class="input-medium" style="display:none"/>
		<form:input path="couponName" htmlEscape="false" class="input-medium" style="display:none"/>
		<ul class="ul-form">
			<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;兑换券批次名称:${couponDetail.couponName}</li>
			<li class="clearfix"></li>
		</ul>
		<ul class="ul-form">
			<li><label>激活状态：</label>
				<form:select path="activatedState" class="input-medium">
					<form:option value="" label="全部"></form:option>
					<form:option value="0" label="未激活"></form:option>
					<form:option value="1" label="已激活"></form:option>
					<form:option value="2" label="已作废"></form:option>
				</form:select>
			</li>
			<li><label>使用状态：</label>
				<form:select path="useState" class="input-medium">
					<form:option value="" label="全部"></form:option>
					<form:option value="0" label="未使用"></form:option>
					<form:option value="1" label="已使用"></form:option>
				</form:select>
			</li>
			<li class="clearfix"></li>
		</ul>
		<ul class="ul-form">
			<li><label>兑换券卡号：</label>
				<form:input path="numStart" class="input-medium"/>至
				<form:input path="numEnd" class="input-medium"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询" onclick="return page();"/></li>
			<li class="btns"><input id="btnClear" class="btn btn-primary" type="button" onclick="clearForm()" value="重置"/></li>
			<li class="btns"><input id="btnExport" class="btn btn-primary" type="button" value="导出"/></li>
			<li class="btns"><input id="btnImport" class="btn btn-primary" type="button" value="导入"/></li>
			<li class="clearfix"></li>
		</ul>
		</br>
		<ul class="ul-form">
			<li class="btns"><input id="btnBatchRemarks" class="btn btn-primary" type="button" value="批量备注"/></li>
			<li class="btns"><input id="btnBatchActivate" class="btn btn-primary" type="button" value="批量激活"/></li>
			<li class="btns"><input id="btnBatchUnActivate" class="btn btn-primary" type="button" value="批量未激活"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>兑换券卡号</th>
				<th>密码</th>
				<th>生成时间</th>
				<th>备注</th>
				<th>激活状态</th>
				<th>使用状态</th>
				<shiro:hasPermission name="crab:couponDetail:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="couponDetail">
			<tr>
				<td><a href="${ctx}/crab/couponDetail/form?id=${couponDetail.id}">
					${couponDetail.cardNum}
				</a></td>
				<td>
					${couponDetail.password}
				</td>
				<td>
					<fmt:formatDate value="${couponDetail.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					${couponDetail.remarks}
				</td>
				<td>
					<c:if test="${couponDetail.activatedState==0}">未激活</c:if>
					<c:if test="${couponDetail.activatedState==1}">已激活</c:if>
					<c:if test="${couponDetail.activatedState==2}">已作废</c:if>
				</td>
				<td>
					<c:if test="${couponDetail.useState==0}">未使用</c:if>
					<c:if test="${couponDetail.useState==1}">已使用</c:if>
				</td>
				<shiro:hasPermission name="crab:couponDetail:edit">
				<td>
    				<c:if test="${couponDetail.useState==0}"><shiro:hasPermission name="crab:couponDetail:form"><a href="${ctx}/crab/couponDetail/form?id=${couponDetail.id}">修改</a></shiro:hasPermission></c:if>
					<shiro:hasPermission name="crab:couponDetail:delete"><a href="${ctx}/crab/couponDetail/delete?id=${couponDetail.id}" onclick="return confirmx('确认要删除该兑换券查看吗？', this.href)">删除</a></shiro:hasPermission>
				</td>
				</shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>